<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>
    <script src="<%=request.getContextPath()%>/js/jquery.twbsPagination.js" type="text/javascript"></script>  
    
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgcore.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgdialog.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/OpenDialog.js"></script> 
    <script src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/fileupload.css"/>
    <script type="text/javascript">
    $(document).ready(function () {
	    $('#pagination-demo').twbsPagination({	    	
	        totalPages: ${pageCount},
	        visiblePages: ${pageCount}>10?10:${pageCount},
			startPage:${page},
	        version: '1.1',
	        first: "首页",
	        last: "未页",
	        prev: '上一页',
	        next: '下一页',
	        onPageClick: function (event, page) {	        	
	        	if(page!=${page}){
	        		var params="${params}";
	        		if(params!='choose'){
   					    <%-- document.getElementById("defaultForm").action="<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action?page="+ page +"&rows=10"; --%>
	   					$("#page").val(page);
	 	        		document.getElementById("defaultForm").action="<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action";
 	        		
	        		}
	        		if(params=='choose'){
   					    document.getElementById("defaultForm").action="<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action?params=choose&page="+ page +"&rows=10";
	        		}
         		    document.getElementById("defaultForm").submit();

	        	}	        	
	        }
	    });

    });
    
    <%-- function dele(id)
    {
    	var r=confirm("是否删除？");
    	if(r)
   		{	
    		location.href="<%=request.getContextPath()%>/productAttr/ProductAttr_delete.action?t1.name=${t1.name }&t1.category.id=${t1.category.id}&t1.category.name=${t1.category.name}&page="+${page}+"&id="+id;
   		}
    	
    } --%>
    
    </script>
</head>

<body>
<div class="panel panel-primary">
    <div class="panel-heading">商品属性管理</div>
    

<c:if test="${params!='choose' }">
    <div class="panel-body"> 
		<form class="form-horizontal" id="defaultForm" action="<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action" method="post">
		  	<table>
		  		<tr>
		  			<td><input type="text" name="t1.name" class="form-control" id="name" placeholder="请输入属性名称" style="width: 150px"  value="${t1.name}"></td>
		  			<td><button type="submit" class="btn btn-default">查询</button></td>
		  			<td>
		  				<input type="hidden" name="t1.category.id"  value="${t1.category.id}">
		  				<input type="hidden" name="t1.groupId"  value="${t1.groupId}">
		  				<input type="hidden" name="params"  value="${params}">
		  				<input type="hidden" id="page" name="page"  value="">
		  				<input type="hidden" id="rows" name="rows"  value="10">
		  			</td>
		  			<c:if test="${params=='productAttrMng' }">
			  			<c:if test="${isShowBlank!=true }"><td><button type="button" onclick="location.href='<%=request.getContextPath()%>/productAttr/ProductAttr_toAdd?t.category.id=${t1.category.id}&t.category.name=${t1.category.name}&t.groupId=${t1.groupId }'" class="btn btn-default">增加</button></td>
			  		   	</c:if>
			  		    <td><button type="button" onclick="location.href='<%=request.getContextPath()%>/productAttr/ProductAttr_excelExport.action?t1.name=${t1.name}&t1.category.id=${t1.category.id}'" class="btn btn-default">导出Excel</button></td>
			  		    <td><button type="button" onclick="location.href='<%=request.getContextPath()%>/productAttr/ProductAttr_downloadTemplet.action'" class="btn btn-default">模板下载</button></td>
			  		    <td>
			  				<input id="detailsDocumentUpload" type="file" name="file" onchange="ajaxFileUpload('productAttr/ProductAttr_uploadExeclData.action')" /> 
	     					<input type="button"  class="btn btn-default" value="Excel上传" onclick="javascript:detailsDocumentUpload.click()" />
			  			</td>
		  			</c:if>
		  		</tr>
		  	</table>
		</form>
 
    </div>
  
  
        <table class="table table-bordered table-hover">
            <thead>
			    <tr>
					 <th>属性名称</th>
					 <th>4级类别名称</th>
					 <th>是否为关键属性</th>
					 <th>创建时间</th>
					 <th>创建人</th>
			         <th>操作</th>
			    </tr>
		    </thead>
		    <s:iterator value="#list">
			    <tr>
					 <th>${name}</th>
					 <th>${category.name}</th>
					 <th>
					     <c:if test="${isKeyAttr==1 }">是</c:if>
					     <c:if test="${isKeyAttr==0 }">否</c:if>
					 </th>
					 <th><fmt:formatDate value="${creationTime}" pattern="yyyy-MM-dd HH:mm:ss"/></th>
					 <th>${creator}</th>
			        <th>
			        <c:if test="${params=='productAttrMng' }">
				        <a class="btn btn-primary btn-sm" href="<%=request.getContextPath()%>/productAttr/ProductAttr_get.action?t1.name=${t1.name }&page=${page}&id=${id }" role="button" >修改</a>
			            <%-- <a class="btn btn-primary btn-sm" onclick="dele(${id })" href="#" role="button" >删除</a> --%>
			            <a class="btn btn-primary btn-sm" href=
			            "<%=request.getContextPath()%>/productAttrDict/ProductAttrDict_exportDictByAttr?t1.productAttr.id=${id}&attrGroupName=${attrGroupName}&categoryName=${category.name}&attrName=${name}&isKeyAttr=${isKeyAttr==1 }" >数据字典导出</a>
			            <a class="btn btn-primary btn-sm" href="<%=request.getContextPath()%>/productAttrDict/ProductAttrDict_listByPage?t1.productAttr.id=${id}" >管理属性值数据字典</a>
			         </c:if>
			         <c:if test="${params=='productAttrMappingMng' }">
			         	<a class="btn btn-primary btn-sm" href="<%=request.getContextPath()%>/productAttr/ProductAttrMapping_listByPage?t1.MAttrId=${id}" >管理属性映射</a>
			         </c:if>
			        </th>
			    </tr>        
		    </s:iterator>
		</table>   
		
</c:if> 

<c:if test="${params=='choose' }">
    <div class="panel-body"> 

		<form class="form-horizontal" id="defaultForm" action="ProductAttr_listByPage.action?params=${params}" method="post">
		  	<table>
		  		<tr>
		  			<td><input type="text" name="t1.name" class="form-control" id="name" placeholder="请输入属性名称" style="width: 150px"  value="${t1.name}"></td>
		  			<td><input type="text" name="t1.category.name" class="form-control" placeholder="请输入4级类别名称" style="width: 150px"  value="${t1.category.name}"></td>
		  			    <input type="hidden" name="t1.category.id" value="${t1.category.id}">
		  			<td><button type="submit" class="btn btn-default">查询</button></td>
		  		</tr>
		  	</table>
		</form>
 
    </div>
  
  
        <table class="table table-bordered table-hover">
            <thead>
			    <tr>
					 <th>属性名称</th>
					 <th>属性组名称</th>
					 <th>4级类别名称</th>
			         <th>操作</th>
			    </tr>
		    </thead>
		    <s:iterator value="#list">
			    <tr>
					 <th>${name}</th>
					 <th>${groupId}</th>
					 <th>${category.name}</th>
			        <th>
				        <input type="hidden" name="nameChoose" id="${id }" value="${name }"/>
						<input type="radio" name="idChoose" value="${id }"/>
			        </th>
			    </tr>        
		    </s:iterator>
		</table>  
</c:if>

</div>
		
<section id="main-content">
    <p>
        <div class="text-center" display="inline">
            <ul id="pagination-demo" class="pagination-sm">&nbsp;&nbsp;&nbsp;共${pageCount}页,共${recordsCount}条记录</ul>
        </div>
    </p>
</section> 

</body>
</html>
